import { Button } from 'antd';

import React, { memo } from 'react';
import { withRouter } from 'react-router';
import './style.less';

export default withRouter(
  memo(function NotFound(props) {
    const backIndex = () => {
      const token = window.localStorage.getItem('token');
      if (token) {
        props.history.push('/main');
      } else {
        props.history.push('/login');
      }
    };
    return (
      <div className="not-found">
        <h2>404 Not found</h2>
        <Button type="primary" onClick={() => backIndex()}>
          返回首页
        </Button>
      </div>
    );
  }),
);
